import QtQuick
import QtQuick.Controls.Material


Item {

    width: buttonWidth
    height: buttonHeight

    property real buttonWidth : 200
    property real buttonHeight : 70

    property var pressedColor: Gradient {
        orientation: Gradient.Vertical
        GradientStop { position: 0.0 ; color: "#FFFFFF"}
        GradientStop { position: 0.5 ; color: "#FFA500"}
        GradientStop { position: 1.0 ; color: "#FFFFFF"}
    }
    property var releasedColor: Gradient {
        orientation: Gradient.Vertical
        GradientStop { position: 0.0 ; color: "#FFFFFF"}
        GradientStop { position: 0.5 ; color: "#1E90FF"}
        GradientStop { position: 1.0 ; color: "#FFFFFF"}
    }

    property real contentText_Fontsize: Cpp_Config.Language_Type === 1 ? 35 :  Cpp_Config.Language_Type === 2 ? 20 : 20
    property string contentText_Data: "按钮文本"
    property string contentText_Color: "black"
    property bool contentText_Bold: true

    property real contentRectangle_BorderWidth: 3
    property string contentRectangle_BorderColor: "black"


    signal buttonClicked()
    signal buttonPressed()
    signal buttonReleased()
    signal buttonPressedAndHold()

    Button{
        id: button
        width: buttonWidth
        height: buttonHeight

        background: Rectangle{
            id: contentRectangle
            anchors.fill: parent
            radius: 10
            border.width: contentRectangle_BorderWidth
            border.color: contentRectangle_BorderColor
            gradient: releasedColor
        }

        contentItem: Rectangle {
            width: buttonWidth
            height: buttonHeight            
            color: "transparent"
            Text{
                anchors.centerIn: parent
                font.pixelSize: contentText_Fontsize
                font.bold: contentText_Bold
                color: contentText_Color
                text: qsTr(contentText_Data)
            }
        }        

        onClicked: {
            buttonClicked()
        }

        onPressed: {
            buttonPressed()
            contentRectangle.gradient = pressedColor
        }

        onReleased: {
            buttonReleased()
            contentRectangle.gradient = releasedColor
        }

        onPressAndHold: {
            buttonPressedAndHold()
        }

    }

}
